<template>
  <div class="page luckdraw-mobile">
    <div class="luckdraw-mobile-container">
      <div class="content">
        <i :style="phoneCheckedBg"></i>
        <p>绑定的手机号：{{phone}}</p>
      </div>
      <div class="btn-section">
        <div class="btn-inner">
          <m-button text="更换手机号" @onClick="onChangePhoneClick"></m-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import MInput from 'comp/m-input'
import MButton from 'comp/m-button'
import mixins from 'comp/mixins'

export default {
  mixins: [mixins],
  components: {
    MInput,
    MButton
  },
  data () {
    return {
      icons: {
        phoneChecked: `${require('static/images/phone-checked.png')}`
      },
      phone: ''
    }
  },
  computed: {
    phoneCheckedBg () {
      return `background-image: url(${this.icons.phoneChecked});`
    }
  },
  mounted () {
    this.resetData()
    this.getPhone()
  },
  methods: {
    onChangePhoneClick () {
      wx.navigateTo({
        url: `/pages/mobile-edit/main`,
      })
    },
    async getPhone () {
      const openId = await this.getOpenId()
      const ret = await this.$store.dispatch('getPlayerInfo', {
        playerid: openId
      })
      if (ret && ret.phone) {
        this.phone = ret.phone.replace(/(\d{3})(\d{4})(\d{4})/, '$1****$3')
      }
    }
  }
}
</script>

<style lang="less" scoped>
.luckdraw-mobile {
  background-color: #fff;
  .content {
    font-size: 32rpx;
    color: #333;
    text-align: center;
    padding: 70rpx 20rpx 30rpx;
    i {
      display: block;
      width: 367rpx;
      height: 290rpx;
      background-size: contain;
      background-repeat: no-repeat;
      background-position: center center;
      margin: 0 auto;
    }
    p {
      padding-top: 70rpx;
    }
  }
  .btn-section {
    width: 100%;
    margin-top: 30rpx;
    .btn-inner {
      padding: 20rpx 20rpx;
    }
  }
}
</style>
